package com.ycw.servlet.guoguo;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;
import com.ycw.dao.HouseRepairDao;
import com.ycw.dao.impl.HouseRepairDaoImpl;

/**
 * Servlet implementation class ShowHouseRepairDataByIDServlet
 */
@WebServlet("/showHouseRepairDataByIDServlet")
public class ShowHouseRepairDataByIDServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request, response);
	}

	/**
	 * 根据请求的hr_id返回修缮信息
	 */
	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		String id = request.getParameter("hr_id");
		HouseRepairDao hrd = HouseRepairDaoImpl.getInstance();
		Integer hr_id = Integer.parseInt(id);
		// 得到修缮表的详细信息
		Map<String, Object> map = hrd.queryHouseRepairDataByID(hr_id);

		String resJSNO = JSON.toJSONString(map);
		PrintWriter out = response.getWriter();
		out.write(resJSNO);

	}

}
